﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using LL.Business;
using LL.Common;

namespace LL.Business
{
    public class SortService : ServiceBase
    {
        public void Swap<T>(object id1, object id2)
        {
            if (!typeof(T).Is<ISort>())
                throw new InvalidOperationException("T类型必须实现ISort接口");

            var obj1 = DbSession.Get<T>(id1).As<ISort>();
            var obj2 = DbSession.Get<T>(id2).As<ISort>();

            var sort = obj1.Sort;
            obj1.Sort = obj2.Sort;
            obj2.Sort = sort;

            DbSession.Update(obj1);
            DbSession.Update(obj2);
        }

    }
}
